using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Firestarter.DB.Schema.Logic
{
    public class CreateTableSqlBuilder_Access : CreateTableSqlBuilder
    {
        public CreateTableSqlBuilder_Access(string tableName) : base(tableName) { }


        protected override string GetColumnAutoIncrementSQL(bool autoIncrementing)
        {
            return autoIncrementing ? "IDENTITY(1,1)" : "";
        }

        protected override string Enclose(string name)
        {
            return string.Format("[{0}]", name);
        }

        public override void AddForeignKey(string foreignKeyName, string parentColumnNameList, string referencedTableName, string referencedColumnNameList)
        {
            string createForeignKeyString = string.Format
                ("CONSTRAINT {0} FOREIGN KEY ({1}) REFERENCES {2} ({3})", Enclose(foreignKeyName), EncloseList(parentColumnNameList),
                 Enclose(referencedTableName), EncloseList(referencedColumnNameList));
            ForeignKeys.Add(createForeignKeyString);
            //return this;
        }

        public override void AddUniqueKey(string keyName, string columnNameList)
        {
            string createUniqueKey = string.Format("CONSTRAINT {0} UNIQUE ({1})", Enclose(keyName), EncloseList(columnNameList));
            UniqueKeys.Add(createUniqueKey);
            //return this;
        }
    }
}
